
import { defineStore } from "pinia"

export const useAdminInfoStore = defineStore('adminInfo', {
    state: () => ({
        loginStatus: false,
        id: 0,
        username: '',
        sex: 0,
        token: '',
        chatSessionId: '',
        role: 0,
        avatar: '',
        chatMessages: [
            {
                content: '你好，有什么可以帮助你的？',
                isUser: false,
                docRefs: []
            }
        ]
    }),
    actions: {
        setLoginStatus(loginStatus: boolean) {
            this.loginStatus = loginStatus;
        },
        setToken(token: string) {
            this.token = token;
        },
        setChatSessionId(chatSessionId: string) {
            this.chatSessionId = chatSessionId;
        },
        setSex(sex: number) {
            this.sex = sex;
        },
        setId(id: number) {
            this.id = id;
        },
        setAvatar(avatar: string) {
            this.avatar = avatar
        },
        setRole(role: number) {
            this.role = role
        },
        setUsername(username: string) {
            this.username = username
        },
        addChatMessage(message: any) {
            this.chatMessages.push(message);
        },
        clearChatMessages() {
            this.chatMessages = [];
        }
    },
    getters: {
        getLoginStatus: (state) => {
            return state.loginStatus;
        },
        getToken: (state) => {
            return state.token;
        },
        getChatSessionId: (state) => {
            return state.chatSessionId;
        },
        getId: (state) => {
            return state.id;
        },
        getRole: (state) => {
            return state.role;
        },
        getUsername: (state) => {
            return state.username;
        },
        getAvatar: (state) => {
            return state.avatar;
        },
        getSex: (state) => {
            return state.sex;
        },
        getChatMessages: (state) => {
            return state.chatMessages;
        }
    }
})

